package com.shyroke.daydayzhuandao.respository;

import com.shyroke.daydayzhuanapi.dto.LabelCountDto;
import com.shyroke.daydayzhuanapi.entity.LabelEntity;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface LabelRepository extends BaseRepository<LabelEntity,Integer>{
    LabelEntity findByLabelName(String key);

    List<LabelEntity> findByIsShowTitle(int isShowTitle);

    List<LabelEntity> findByLabelNameLike(String key);

    List<LabelEntity> findByIdIn(List<Integer> labelIdList);

    @Query(value = "select labelid,count(labelid) as count from project_label pl  left join label l on pl.labelid = l.id where l.is_show_title = '0'  GROUP BY labelid order by read_count desc limit 30 ",nativeQuery = true)
    List<Map<String,Integer>> findByLabelCount();

    List<LabelEntity> findByType_IdAndIsTop(Integer typeId, boolean isTop);
}
